<?php

namespace app\http\controller;


class Base
{
    protected string $controller;
    protected string $action;
    protected array $response;
    protected int $status = 200;
    protected string $message = 'Success';

    /**
     * @return string
     */
    public function getController(): string
    {
        return $this->controller;
    }

    /**
     * @param string $controller
     * @return Base
     */
    public function setController(string $controller): Base
    {
        $this->controller = $controller;
        return $this;
    }

    /**
     * @return string
     */
    public function getAction(): string
    {
        return $this->action;
    }

    /**
     * @param string $action
     * @return Base
     */
    public function setAction(string $action): Base
    {
        $this->action = $action;
        return $this;
    }

    /**
     * @return array
     */
    public function getResponse(): array
    {
        return $this->response;
    }

    /**
     * @param array $response
     * @return Base
     */
    public function setResponse(array $response): Base
    {
        $this->response = $response;
        return $this;
    }

    /**
     * @return string
     */
    public function getMessage(): string
    {
        return $this->message;
    }

    /**
     * @param string $message
     * @return Base
     */
    public function setMessage(string $message): Base
    {
        $this->message = $message;
        return $this;
    }

    /**
     * @return int
     */
    public function getStatus(): int
    {
        return $this->status;
    }

    /**
     * @param int $status
     */
    public function setStatus(int $status): void
    {
        $this->status = $status;
    }


    public function message()
    {
        return json_encode([
            'status' => $this->status,
            'message' => $this->message,
            'response' => [
                'controller' => $this->controller,
                'action' => $this->action,
                'data' => $this->response
            ]
        ]);
    }

}